from pymongo import MongoClient
from mybusiness.settings import mongo_port
from mybusiness.settings import mongo_db
from mybusiness.settings import mongo_jh


class PyMongo:

    def __init__(self, db, jh, **mongo_kwargs):
        self.da = MongoClient(**mongo_kwargs)
        self.db = self.da[db]
        self.__db = self.db[jh]

    def insert(self,val):
        self.__db.insert_one(val)

    def find(self):
        return self.__db.find()


# m = PyMongo(mongo_db, mongo_jh, **mongo_port)
# m.insert({'name':'zhangsan'})
# for i in m.find({'name':'zhangsan'}):
#     print(i)


